From 6218584db8e56f612c5bf2fb91a523806b805f42 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Thu, 1 Mar 2018 11:25:46 -0500 Subject: [PATCH] One more todo to fix --- src/cargo/core/resolver/mod.rs | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 3859005b2..26c4d0a37 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -797,21 +797,19 @@ fn activate_deps_loop<'a>( }) })?; - // We have a candidate. Add an entry to the `backtrack_stack` so - // we can try the next one if this one fails. - if has_another { - // TODO: when to push this vs. activation error - backtrack_stack.push(BacktrackFrame { - cur, - context_backup: Context::clone(&cx), - deps_backup: >::clone(&remaining_deps), - remaining_candidates: remaining_candidates.clone(), - parent: Summary::clone(&parent), - dep: Dependency::clone(&dep), - features: Rc::clone(&features), - conflicting_activations: conflicting_activations.clone(), - }); - } + // We have a candidate. Clone a `BacktrackFrame` + // so we can add it to the `backtrack_stack` if activation succeeds. + // We clone now in case `activate` changes `cx` and then fails. + let backtrack = BacktrackFrame { + cur, + context_backup: Context::clone(&cx), + deps_backup: >::clone(&remaining_deps), + remaining_candidates: remaining_candidates.clone(), + parent: Summary::clone(&parent), + dep: Dependency::clone(&dep), + features: Rc::clone(&features), + conflicting_activations: conflicting_activations.clone(), + }; let method = Method::Required { dev_deps: false, @@ -821,6 +819,7 @@ fn activate_deps_loop<'a>( trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(), candidate.summary.version()); let res = activate(&mut cx, registry, Some(&parent), candidate, &method); successfully_activated = res.is_ok(); + match res { Ok(Some((frame, dur))) => { remaining_deps.push(frame); @@ -830,6 +829,12 @@ fn activate_deps_loop<'a>( Err(ActivateError::Error(e)) => return Err(e), Err(ActivateError::Conflict(id, reason)) => { conflicting_activations.insert(id, reason); }, } + + // Add an entry to the `backtrack_stack` so + // we can try the next one if this one fails. + if has_another && successfully_activated { + backtrack_stack.push(backtrack); + } } } -- 2.30.2